/*!
 * \file GapGenerator.h
 * \brief Generator for GAP state machine in Media Gateway
 */

#ifndef MGW_GAP_GENERATOR_H
#define MGW_GAP_GENERATOR_H

#include "Generator.h"
#include "StateBase.h"
#include "GapGlobals.h"
#include "Timer.h"

namespace tsc
{
namespace mgw
{

/**
 * Generator implementation for GAP protocol in Media Gateway.
 * One GapGenerator corresponds to one Media Gateway which means there
 * is only one in this process.
 */
class GapGenerator : public common::Generator
{
public:

    static GapGenerator& instance();

    void init(common::GeneratorEnvironment& ge);

	virtual ~GapGenerator();

    uint32_t getMgwId() const;
    void setMgwId(const uint32_t id);

    bool txEnabled() const;

    void startT709(unsigned long msValue = T_709_VALUE);
    void cancelT709();

    void startT711(unsigned long msValue = T_711_VALUE);
    void cancelT711();

    unsigned int getSocketConnectionId();

private:
    /**
     * Creates new GapGenerator for handling new signaling connection with
     * Media Gateway
     */
    GapGenerator(common::GeneratorEnvironment& ge);

    common::Timer* mpT709;
    common::Timer* mpT711;

    uint32_t     mMgwId;
    // TODO set this
    unsigned int mSocketConnId;

    static GapGenerator* _instance;
};

} // namespace mgw
} // namespace tsc

#endif // GW_GAP_GENERATOR_H
